﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BonsaiScrum.Bus;
using BonsaiScrum.Core.Command;
using BonsaiScrum.Core.Domain;
using BonsaiScrum.Core.Infrastructure;
using BonsaiScrum.Core.Persistance;

namespace BonsaiScrum.Core.CommandHandlers
{
    public class DisableUserHandler : ICommandHandler<DisableUser>
    {
        private ILogger _logger;
        private IDomainRepository _domainRepository;

        public DisableUserHandler(ILogger logger, IDomainRepository domainRepository)
        {
            _logger = logger;
            _domainRepository = domainRepository;
        }

        public void Handle(DisableUser message)
        {
            User user;
            user = _domainRepository.GetById<User>(message.UserId);
            _logger.Debug("A user '{0}' has been disabled.", message.UserId);
            user.Disable();

        }
    }
}
